package com.jwater.core.manager.job.timer;

import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

import jwater.org.quartz.Job;
import jwater.org.quartz.JobExecutionContext;
import jwater.org.quartz.JobExecutionException;

/**
 * @description:
 * @author: jnner
 * @createDate: 2021/2/5
 * @version: 1.0
 */
public class CronJob implements Job {
    protected static Logger logger = LoggerFactory.getLogger(CronJob.class);
    protected CronTimer timer;

    @Override
    public void execute(JobExecutionContext context) throws JobExecutionException {
        timer = (CronTimer) context.getJobDetail().getJobDataMap().get("CronTimer");
        if (timer.isRunning) {
            timer.task.doWork(context.getScheduledFireTime().getTime());
        } else {
            logger.warn("not running");
        }
    }
}
